﻿using System.IO;
using System.Xml.Serialization;

namespace Kikooland
{
    [XmlRoot("Configuration")]
    public class Configuration
    {
        /// <summary>
        /// singleton d'accès à la configuration
        /// </summary>
        private static Configuration _instance = null;

        public static Configuration GetInstance()
        {
            _instance = (_instance == null) ? new Configuration() : _instance;
            return _instance;
        }

        private Configuration()
        {
        }

        public void LoadConfig()
        {
            XmlSerializer x = new XmlSerializer(GetType());
            using (var s = new StreamReader("Configuration.xml"))
            {
                _instance = (Configuration)x.Deserialize(s);
            }
        }

        public void SaveConfig()
        {
            XmlSerializer x = new XmlSerializer(GetType());
            using (var s = new StreamWriter("Configuration.xml", false))
            {
                x.Serialize(s, _instance);
            }
        }

        public bool BarreDeVieMobs
        {
            get
            {
                return true;
                //return this.VoirBarreDeVieMobs == "1" ? true : false;
            }
            set
            {                
                //this.VoirBarreDeVieMobs = value ? "1" : "0";
            }
        }


        #region SerializableMembers

        [XmlElement("VoirBarreDeVieMobs")]
        public string VoirBarreDeVieMobs { get; set; }

        #endregion
    }
}
